NProgress.start();
window.onload = function () {
    NProgress.done();
}
layui.use(['element', 'form', 'jquery'], function () {
    var element = layui.element;
    var form = layui.form;
    var $ = layui.jquery;
    form.on('submit(add)', function (data) {
        $.post("/system/role/update", data.field, function (res) {
            if (res.success) {
                layer.msg("添加成功！", {icon: 6, time: 700, anim: 4}, function () {
                    parent.layui.reload({});
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                });
            } else {
                parent.layer.alert(res.data.errMsg);
            }
        }, 'json');
        return false;
    });

    $("#deptName").click(function () {
        layer.open({
            type: 2,
            title: "选择部门",
            area: ['300px', '450px'],
            content: "/system/dept/treeView"
        })
    });
});
function loadDept(deptId, deptName) {
    document.getElementById("deptId").value = deptId;
    document.getElementById("deptName").value = deptName;
}